package com.endava.Formatting;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexDate {
	/** The class that holds numberFormat method */
	private String regex;
	private String input;

	/** The getter for regex variable */
	public String getRegex() {
		return regex;
	}

	/** The setter for the regex variable */
	public void setRegex(String regex) {
		this.regex = regex;
	}

	/** The getter for input variable */
	public String getInput() {
		return input;
	}

	/** The setter for the input variable */
	public void setInput(String input) {
		this.input = input;
	}
/**	The method that takes 2 parameters of type string
 * @param String that passes the value of the regular expression.
 * @param String that passes the actual input that will be parsed.
 * */
	public String numberFormat(String regex, String input) {
		this.regex = getRegex();
		this.input = getInput();
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(input);
		/**passes to trough the input string*/
		while (m.find()) {//if it find's a value then the expression = true and goes on, if not it goes out of the loop
			System.out.println(m.start() + " " + m.group());//prints the index of the matching regular expression and the value of it
		}
		return input;//returns the new input after parsing
	}
}
